﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Game_Engine
{
    public class ProgressBar : Sprite
    {
        public float Speed
        {
            get;
            set;
        }

        public Sprite Background
        {
            get;
            set;
        }

        public Sprite Foreground
        {
            get;
            set;
        }

        public float Value
        {
            get;
            set;
        }

        public float Max
        {
            get;
            set;
        }

        public ProgressBar(Texture2D foreground, Texture2D background, float v, float s, float m)
        {
            Foreground = new Sprite(foreground);
            Background = new Sprite(background);
            Speed = s;
            Value = v;
            Max = m;
        }

        public void Update(float v)
        {
            Value = v;
            if (Value > Max)
                Value = Max;
            Foreground.Source = new Rectangle(0, 0, (int)(Background.Texture.Width * (Value/Max)), Background.Texture.Height);
        }

        public override void Draw(SpriteBatch sB)
        {
            Background.Draw(sB);
            Foreground.Draw(sB);
        }

    }
}
